package com.unicom.office.func;

import com.unicom.office.matcher.DataMatcher;
import com.unicom.office.runtime.OfficeRuntime;
import com.unicom.office.type.TypeItem;
import com.unicom.office.unit.OfficeUnit;
import com.unicom.office.var.VarItem;

public class VarFunc extends FuncBase {
    private VarItem varItem;

    public VarFunc(VarItem varItem) {
        this.varItem = varItem;
    }

    public TypeItem getType() {
        return varItem.getTypeItem();
    }

    public Object run(OfficeRuntime officeRuntime) {
        return officeRuntime.get(varItem);
    }

    public void runForMatch(OfficeUnit unit, OfficeRuntime officeRuntime) {
        DataMatcher dataMatcher = new DataMatcher(null, unit);
        Object match = dataMatcher.match();
        officeRuntime.set(varItem, match);
    }
}
